package com.group.order.trans;

import com.group.commons.entity.DoctorDto;
import com.group.order.entity.OrderList;
import com.group.order.entity.Registration;
import com.group.order.entity.vo.RegistrationDetailVo;
import com.group.order.entity.vo.RegistrationListVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 挂号单实体类转换接口
 *
 * @author a0112
 * @date 2022/06/07
 */
@Mapper
public interface RegistrationTrans {
    /**
     * 实体类对象
     */
    RegistrationTrans MAPPER = Mappers.getMapper(RegistrationTrans.class);

    /**
     * 挂号单对象转换成前端视图对象
     *
     * @param registration 挂号单表对应实体类
     * @return {@link RegistrationListVo} 挂号单视图对象
     */
    RegistrationListVo convertVo(Registration registration);

    /**
     * 挂号单列表转换成前端视图对象
     *
     * @param list 挂号单列表
     * @return {@link List}<{@link RegistrationListVo}> 视图对象列表
     */
    List<RegistrationListVo> convertVoList(List<Registration> list);

    /**
     * 挂号单详情视图对象
     * 将多个对象组装成视图对象返回给前端
     *
     * @param doctorDto    医生信息
     * @param registration 挂号单信息
     * @param orderList    订单信息
     * @return {@link RegistrationDetailVo} 挂号单详情对象
     */
    @Mapping(target = "doctorName", source = "doctorDto.name")
    @Mapping(target = "orderNumber", source = "orderList.number")
    @Mapping(target = "money", source = "registration.money")
    @Mapping(target = "status", source = "orderList.status" )
    RegistrationDetailVo convertDetailVo(DoctorDto doctorDto, Registration registration, OrderList orderList);
}
